﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

public class Camera2D
{
    #region Fields
    Matrix transformMatrix;
    Vector2 cameraPosition;
    #endregion

    #region Methods
    #endregion

    #region Constructors
    public Camera2D()
    {
        //Set default cameraposition
        cameraPosition = Vector2.Zero;
    }
    public void CalculateMatrix()
    {
        //Only recalculate matrix when it is changed.
        transformMatrix = Matrix.CreateTranslation(new Vector3(-cameraPosition.X, -cameraPosition.Y, 0)) *
               GameEnvironment.SpriteScale *
               Matrix.CreateTranslation(new Vector3(GameEnvironment.InputHelper.Scale.X * GameEnvironment.Screen.X, GameEnvironment.InputHelper.Scale.Y * GameEnvironment.Screen.Y, 0) * 0.5f);
    }
    #endregion

    #region Properties
    public Vector2 CameraPosition { get { return cameraPosition; } set { cameraPosition = value; CalculateMatrix(); } }
    public Matrix TransformMatrix
    {
        get
        {
            return transformMatrix;
        }
    }
    #endregion
}
